﻿var library = (function () {
    HTMLEnCode = function (str) {
        var s = "";
        if (str.length == 0) return "";
        s = str.replace(/&/g, "&gt;");
        s = s.replace(/</g, "&lt;");
        s = s.replace(/>/g, "&gt;");
        s = s.replace(/ /g, "&nbsp;");
        s = s.replace(/\'/g, "'");
        s = s.replace(/\"/g, "&quot;");
        s = s.replace(/\n/g, " <br>");
        return s;
    }
    HTMLDeCode = function (str) {
        var s = "";
        if (str.length == 0) return "";
        s = str.replace(/&gt;/g, "&");
        s = s.replace(/&lt;/g, "<");
        s = s.replace(/&gt;/g, ">");
        s = s.replace(/&nbsp;/g, " ");
        s = s.replace(/'/g, "\'");
        s = s.replace(/&quot;/g, "\"");
        s = s.replace(/ <br>/g, "\n");
        return s;
    }

    return {
        Common: (function () {
            return function () {
                this.Redirect = function (url) {
                    window.location.href = url;
                    if (jQuery.browser.version == '6.0') {
                        window.event.returnValue = false;
                    }
                };
            }
        })(),
        Index: (function () {
            return function () {
                this.Load = function () {
                    new plug.RollBlack().BindControl({
                        orientation: 'up',
                        container: 'dnccontainer',
                        interval: 5000,
                        probability: 0.3,
                        warpwidth: '225px',
                        warpheight: '500px',
                        itemCount: 20,
                        builddata: function () {
                            var source = data.GetDataSource('collage');
                            if (Math.random() < 0.6) {
                                var collect = source[parseInt(Math.random() * 1000, 10) % 11];
                                return '一位来至' + collect.name + '的朋友加入了我们';
                            }
                            var collect = source[parseInt(Math.random() * 1000, 10) % source.length];
                            return '一位来至' + collect.name + '的朋友加入了我们';
                        },
                        buildline: function () {
                            return $('<div class="box1-item3"><div class="box1-item-title" title="' + this.builddata() + '">' + this.builddata().substring(0, 14) + '</div></div>');
                        } 
                   });
                }
            }
        })(),
        Login: (function () {
            var rad = Math.random();
            var interval = null;
            var time = 120;
            ReflashToken = function () {
                rad = Math.random();
                jQuery('input[name="token"]').val(rad);
            };
            setValidtorTimeOut = function () {
                if (interval == null) {
                    interval = window.setInterval(function () {
                        var s = parseInt(time, 10);
                        if (s > 0) {
                            time -= 1;
                        }
                        else {
                            jQuery('#ValidImg').trigger('click');
                        }
                    }, 1000);
                }
            }
            return function () {
                this.BindValidator = function () {
                    jQuery(function () {
                        ReflashToken();
                        jQuery('#codeimg').html('<img alt="点击刷新验证码" id="ValidImg" src="/Account/ValidateToken_t=' + rad + '" alt="点击刷新" onclick="Refalsh(this);" style="width:60px;height:25px;cursor:pointer;"/>');
                        setValidtorTimeOut();
                    });
                }
                this.CBindValidator = function () {
                    jQuery(function () {
                        ReflashToken();
                        jQuery('#codeimg').html('<img alt="点击刷新验证码" id="ValidImg" src="/Account/ValidateToken_t=' + rad + '" alt="点击刷新" onclick="Refalsh(this);" style="width:60px;height:25px;cursor:pointer;"/>');
                        setValidtorTimeOut();
                        $.formValidator.initConfig({ formID: "form1", ErrorTipClass: 'validation-label-error', ErrorElementClass: 'validation-element-error', onSuccess: function (meg) { return true; }, onError: function (msg, obj, errorlist) { return false; } });
                        $('input[name="UserName"]').formValidator({ tipID: 'txtUserNameTip', onShow: ' ', onFocus: '请使用您的常用邮箱作为您的用户名', onError: "输入有误" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", onError: "格式错误，例：\"abc@mail.com\"" }).ajaxValidator({ onError: "该用户名已存在", url: '/account/usernamevalid', data: { username: $(this).val() }, error: function () { return false; }, success: function (result) { if (result == '1') { return false; } return true; } });
                        $('input[name="Password"]').formValidator({ tipID: 'txtPasswordTip', onShow: ' ', onFocus: '请输入密码', onError: "输入有误" }).inputValidator({ min: 6, onError: '至少输入6个字符' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                        $('input[name="Confirm"]').formValidator({ tipID: 'txtConfirmTip', onShow: ' ', onFocus: '请输入确认密码', onError: "输入有误" }).inputValidator({ min: 6, onError: '至少输入6个字符' }).compareValidator({ desID: 'txtPassword', operateor: '=', onError: '两次输入不一致' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                        $('input[name="Validator"]').formValidator({ tipID: 'txtValidatorTip', onShow: ' ', onFocus: '请输入左边验证信息', onError: "输入有误" }).inputValidator({ min: 4, max: 4, onError: '输入有误' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                        $(':checkbox[name="agreementcheck"]').formValidator({ tipID: 'agreementcheckTip', onShow: ' ', onFocus: ' ', onError: " " }).inputValidator({ min: 1, onError: '如果您同意服务声明请打勾' })
                    });
                };
                this.BBindValidator = function () {
                    jQuery(function () {
                        ReflashToken();
                        jQuery('#codeimg').html('<img alt="点击刷新验证码"  id="ValidImg" src="/Account/ValidateToken_t=' + rad + '" alt="点击刷新" onclick="Refalsh(this);" style="width:60px;height:25px;cursor:pointer;"/>');
                        setValidtorTimeOut();
                        $.formValidator.initConfig({ formID: "form1", ErrorTipClass: 'validation-label-error', ErrorElementClass: 'validation-element-error', onSuccess: function (meg) { return true; }, onError: function (msg, obj, errorlist) { return false; } });
                        $('input[name="UserName"]').formValidator({ tipID: 'txtUserNameTip', onShow: ' ', onFocus: '请使用您的常用邮箱作为您的用户名', onError: "输入有误" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", onError: "格式错误，例：\"abc@mail.com\"" }).ajaxValidator({ onError: "该用户名已存在", url: '/account/usernamevalid', data: { username: $(this).val() }, error: function () { return false; }, success: function (result) { if (result == '1') { return false; } return true; } });
                        $('input[name="CompanyName"]').formValidator({ tipID: 'txtCompanyNameTip', onShow: '', onFocus: '请输入您的企业名', onError: "输入有误" }).inputValidator({ min: 3, onError: '至少输入3个字符' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                        $('input[name="Email"]').formValidator({ tipID: 'txtEmailTip', onShow: ' ', onFocus: '请输入您的企业邮箱', onError: "输入有误" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", onError: "格式错误，例：\"abc@mail.com\"" });
                        $('input[name="Phone"]').formValidator({ tipID: 'txtPhoneTip', onShow: '', onFocus: '请输入联系电话', onError: "输入有误" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                        $('input[name="Location"]').formValidator({ tipID: 'txtLocationTip', onShow: ' ', onFocus: '请输入联系地址', onError: "输入有误" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                        $('input[name="Password"]').formValidator({ tipID: 'txtPasswordTip', onShow: ' ', onFocus: '请输入密码', onError: "输入有误" }).inputValidator({ min: 6, onError: '至少输入6个字符' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                        $('input[name="Confirm"]').formValidator({ tipID: 'txtConfirmTip', onShow: ' ', onFocus: '请输入确认密码', onError: "输入有误" }).inputValidator({ min: 6, onError: '至少输入6个字符' }).compareValidator({ desID: 'txtPassword', operateor: '=', onError: '两次输入不一致' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                        $('input[name="Validator"]').formValidator({ tipID: 'txtValidatorTip', onShow: ' ', onFocus: '请输入左边验证信息', onError: "输入有误" }).inputValidator({ min: 4, max: 4, onError: '输入有误' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                        $('input[name="QQ"]').formValidator({ tipID: 'txtQQTip', onShow: ' ', onFocus: '请输入常用QQ号', onError: " ", empty: true }).regexValidator({ regExp: "^\\d{5,15}$", onError: "格式错误，QQ号应为5-15位的数字" }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                        $(':checkbox[name="agreementcheck"]').formValidator({ tipID: 'agreementcheckTip', onShow: ' ', onFocus: ' ', onError: " " }).inputValidator({ min: 1, onError: '如果您同意服务声明请打勾' })
                    });
                };
                this.Refalsh = function (sender) {
                    ReflashToken();
                    time = 120;
                    jQuery('#Validator').val('');
                    jQuery(sender).attr('src', '/Account/ValidateToken_t=' + rad);

                };
            };
        })(),
        Recruiting: (function () {
            var length = 1;
            var templete = {
                recruiting: { Data: [], ItemTotle: 0, TotlePage: 0, NextPage: 0, PrePage: 0 },
                company: { Data: [], ItemTotle: 0, TotlePage: 0, NextPage: 0, PrePage: 0 }
            };
            LoadDateFormat = function (ms, sptChar) {
                var date = new Date(ms);
                return date.toLocaleDateString().replace('年', '-').replace('月', '-').replace('日', '');
                //return date.getYear().toString() + sptChar + date..getMonth().toString() + sptChar + date.getDay().toString();
            },
            LoadRecruitingTempleties = function (recruitingStr) {
                var string = HTMLDeCode(recruitingStr);
                var obj = eval('(' + string + ')');
                if (obj.Data.length > 0) {
                    templete.recruiting.ItemTotle = obj.ItemTotle;
                    templete.recruiting.TotlePage = obj.TotlePage;
                    templete.recruiting.NextPage = obj.NextPage;
                    templete.recruiting.PrePage = obj.PrePage;
                    templete.recruiting.Data = [];
                    for (var i = 0, len = obj.Data.length; i < len; i++) {
                        var item = {};
                        item.ID = obj.Data[i].Id;
                        item.Title = obj.Data[i].Caption;
                        item.PostDate = new Date(parseInt(/\d+/.exec(obj.Data[i].PublishDate), 10)).toLocaleDateString();
                        templete.recruiting.Data.push(item);
                    }
                }
            };
            LoadCompanyTempleties = function (employerStr) {
                var html = HTMLDeCode(employerStr);
                var obj = eval('(' + html + ')');
                if (obj.Data.length > 0) {
                    templete.company.ItemTotle = obj.ItemTotle;
                    templete.company.TotlePage = obj.TotlePage;
                    templete.company.NextPage = obj.NextPage;
                    templete.company.PrePage = obj.PrePage;
                    templete.company.Data = [];
                    for (var i = 0, len = obj.Data.length; i < len; i++) {
                        var item = {};
                        item.ID = obj.Data[i].Id,
                        item.Title = obj.Data[i].CompanyName,
                        item.PostDate = new Date(parseInt(/\d+/.exec(obj.Data[i].PostDate), 10)).toLocaleDateString();
                        templete.company.Data.push(item);
                    }
                }
            };
            /*
            模板的html段：
            <div style="display:none;width:400px;height:280px;" class="templetebox">
            <div style="display:none;" class="loadData">{当选择了模板以后，这里会添加<div>数据加载中，请稍后......</div>，在ajax请求返回后，这个div会被移除，并将外层div影藏掉}</div>
            <div id="recruitingTempBox">
            <ul>
            <li><a href="javascript:;" onclick="Recovery(this,[ID],1)">创建于[PostDate]-[Title]</a></li>
            <li><a href="javascript:;" onclick="Recovery(this,[ID],1)">创建于[PostDate]-[Title]</a></li>
            </ul>
            <div>共([ItemTotle])条记录/([TotlePage])页 
            <a href="javascript:;" onclick="GoPage(this,[PrePage],1)">上一页</a>
            <a href="javascript:;" onclick="GoPage(this,[NextPage],1)">下一页</a>
            {当点击翻页过后，这里会加上一段<span>请稍后......</span>。在ajax请求返回后，这个span会被移除}
            </div>
            </div>
            <a href="javascript:;" id="btncolsetemp">关闭</a>
            </div>
            **/
            BuildRecruitingTemplete = function (recruitingboxId) {
                var recruitingbox = $('#' + recruitingboxId);
                if (recruitingbox.length > 0) {
                    recruitingbox.each(function () {
                        $(this).html('');
                        var segment = $('<ul/>');
                        for (var i = 0, len = templete.recruiting.Data.length; i < len; i++) {
                            segment.append($('<li><a href="javascript:;" onclick="Recovery(this,' + templete.recruiting.Data[i].ID + ',1)">' + templete.recruiting.Data[i].Title + '</a></li>'));
                        }
                        $(this).append(segment);
                        $(this).append($('<div>共(' + templete.recruiting.ItemTotle + ')条记录/(' + templete.recruiting.TotlePage + ')页 <a href="javascript:;" onclick="GoPage(this,' + templete.recruiting.PrePage + ',1)">上一页</a><a href="javascript:;" onclick="GoPage(this,' + templete.recruiting.NextPage + ',1)">下一页</a></div>'));
                    });
                }
            }
            BuildCompanyTemplete = function (companyboxId) {
                var companybox = $('#' + companyboxId);
                if (companybox.length > 0) {
                    companybox.each(function () {
                        $(this).html('');
                        var segment = $('<ul/>');
                        for (var i = 0, len = templete.company.Data.length; i < len; i++) {
                            segment.append($('<li><a href="javascript:;" onclick="Recovery(this,' + templete.company.Data[i].ID + ',0)">' + templete.company.Data[i].Title + '</a></li>'));
                        }
                        $(this).append(segment);
                        $(this).append($('<div>共(' + templete.recruiting.ItemTotle + ')条记录/(' + templete.recruiting.TotlePage + ')页 <a href="javascript:;" onclick="GoPage(this,' + templete.company.NextPage + ',0)">上一页</a><a href="javascript:;" onclick="GoPage(this,' + templete.company.NextPage + ',0)">下一页</a></div>'));
                    });
                }
            },
            SetRecruitingSheet = function (data) {
                var obj = eval('(' + data + ')');
                $('input[name="Caption"]').val(obj.Caption);
                $('input[name="ContactMan"]').val(obj.Contact);
                $('input[name="ContactPhone"]').val(obj.ContactPhone);
                $('select[name="WorkArea"]').val(obj.WorkArea);
                $('input[name="WorkAddress"]').val(obj.WorkAddress);
                $('input[name="QQ"]').val(obj.QQ);
                //$('#txtDescription').val(obj.RecruitSheet.Description);
                if (obj.EnableEmail) {
                    $('input[name="EnableEmail"]').attr('checked', 'checked');
                    $('#rcebox').show();
                    $("input[name='ReceiveEmail']").val(obj.ReceiveEmail);
                    $("input[name='ReceiveEmail']").formValidator({ tipID: 'txtReceiveEmailTip', onShow: ' ', onFocus: ' ', onError: "请输入用于接收求职者简历的邮箱地址" }).regexValidator({ regExp: "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", onError: "您的输入有误" }); ;
                }
                if (obj.Positions[0].Priority) {
                    $('input[name="Priority"]').attr('checked', 'checked');
                }
                if (obj.RecruitType == '2') {
                    $('input[name="RecruitType"]').attr('checked', 'checked');
                }
                $('#positionbox .positionitem').each(function () {
                    var o = $(this).children('div').eq(0).children('.right').children('a');
                    if (o.length > 0) {
                        o.trigger('click');
                    }
                });
                length = 1;
                var positions = obj.Positions;
                for (var i = 0, len = positions.length; i < len; i++) {
                    if (i != 0) {
                        $('#btnAddPosition').trigger('click');
                    }
                    $('input[name="PositionName' + i + '"]').val(positions[i].PositionName);
                    $('input[name="Vacancy' + i + '"]').val(positions[i].Vacancy);
                    $('select[name="PositionType' + i + '"]').val(positions[i].PositionType);
                    $('input[name="MinSalary' + i + '"]').val(positions[i].MinSalary);
                    $('input[name="MaxSalary' + i + '"]').val(positions[i].MaxSalary);
                    $('select[name="Period' + i + '"]').val(positions[i].Period);
                    $('select[name="Gender' + i + '"]').val(positions[i].Gender);
                    $('select[name="Degree' + i + '"]').val(positions[i].Degree);
                    if (positions[i].Experienced) {
                        $('input[name="Experienced' + i + '"]').attr('checked', 'checked');
                    }
                    if (positions[i].PositionDescript.length > 0) {
                        $('#btnAddNote' + i).trigger('click');
                        $('textarea[name="PositionDescript' + i + '"]').val(positions[i].PositionDescript.replace(/\<br\/\>/ig, '\r\n'));
                    }
                }
                $('input[name="DepositCompanyId"]').val(obj.DepositCompany.Id);
                $('input[name="CompanyName"]').val(obj.DepositCompany.CompanyName);
                $('select[name="CompanyBusiness"]').val(obj.DepositCompany.CompanyBusiness);
                $('select[name="CompanyType"]').val(obj.DepositCompany.CompanyType);
                $('select[name="CompanyDimensions"]').val(obj.DepositCompany.CompanyDimensions);
                $('#txtCompanyDetail').val(obj.DepositCompany.CompanyDetail);
            },
            RecoveryRecritingData = function (sender, id) {
                var label = $('<div>数据加载中，请稍后......</div>');
                $.ajax({
                    url: '/CompanyCenter/GetRecruitingTempelte',
                    data: { id: id },
                    beforeSend: function () {
                        $(sender).parents('ul').parent().siblings('.loadData').append(label).show();
                    },
                    success: function (data) {
                        SetRecruitingSheet(data);
                    },
                    complete: function () {
                        $('#btncolsetemp').trigger('click');
                        $(sender).parents('ul').parent().siblings('.loadData').hide();
                        label.remove();
                    }
                });
            }
            RecoveryCompanyData = function (sender, id) {
                var label = $('<div>数据加载中，请稍后......</div>');
                $.ajax({
                    url: '/CompanyCenter/GetCompanyTemplete',
                    data: { id: id },
                    beforeSend: function () {
                        $(sender).parents('ul').parent().siblings('.loadData').append(label).show();
                    },
                    success: function (data) {
                        var obj = eval('(' + data + ')');
                        $('input[name="DepositCompanyId"]').val(obj.Id);
                        $('input[name="CompanyName"]').val(obj.CompanyName);
                        $('select[name="CompanyBusiness"]').val(obj.CompanyBusiness);
                        $('select[name="CompanyType"]').val(obj.CompanyType);
                        $('select[name="CompanyDimensions"]').val(obj.CompanyDimensions);
                        $('#txtCompanyDetail').val(obj.CompanyDetail);
                    },
                    complete: function () {
                        $('#btncolsecompanyTemp').trigger('click');
                        $(sender).parents('ul').parent().siblings('.loadData').hide();
                        label.remove();
                    }
                });
            }
            return function () {
                this.BindValidate = function () {
                    $.formValidator.initConfig({ formID: "form1", ErrorTipClass: 'validation-label-error', ErrorElementClass: 'validation-element-error', onSuccess: function (meg) { return true; }, onError: function (msg, obj, errorlist) { return false; } });
                    $("input[name='Caption']").formValidator({ tipID: 'txtCaptionTip', onShow: ' ', onFocus: "请输入具有概括性的标题", onError: "至少输入5个字符" }).inputValidator({ min: 5, onError: '至少输入5个字符' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("input[name='ContactMan']").formValidator({ tipID: 'txtContactManTip', onShow: ' ', onFocus: ' ', onError: "请输入联系人" }).inputValidator({ min: 1, onError: '请输入联系人' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("input[name='ContactPhone']").formValidator({ tipID: 'txtContactPhoneTip', onShow: ' ', onFocus: ' ', onError: "请输入联系电话" }).inputValidator({ min: 1, max: 30, onError: '请输入联系电话' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("input[name='WorkAddress']").formValidator({ tipID: 'txtWorkAddressTip', onShow: ' ', onFocus: ' ', onError: "请输入兼职详细工作地址" }).inputValidator({ min: 1, onError: '请输入兼职详细工作地址' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    //$("#txtDescription").formValidator({ tipID: 'txtDescriptionTip', onShow: ' ', onFocus: ' ', onError: "详细的兼职描述有助于更快的通过审核和找寻人才" }).inputValidator({ min: 1, onError: '详细的兼职描述有助于更快的通过审核和找寻人才' });
                    $('input[name="PositionName0"]').formValidator({ tipID: 'txtPositionName0Tip', onShow: ' ', onFocus: ' ', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $('input[name="Vacancy0"]').formValidator({ tipID: 'txtVacancy0Tip', onShow: ' ', onFocus: ' ', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^\\d+$", onError: "格式错误" });
                    $('textarea[name="PositionDescript0"]').formValidator({ tipID: 'txtPositionDescript0Tip', onShow: ' ', onFocus: ' ', onError: "职位描述不能为空" }).inputValidator({ min: 1, onError: '职位描述不能为空' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $('input[name="CompanyName"]').formValidator({ tipID: 'txtCompanyNameTip', onShow: ' ', onFocus: " ", onError: "请输入招聘企业名称" }).inputValidator({ min: 1, onError: '请输入招聘企业名称' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("#txtCompanyDetail").formValidator({ tipID: 'txtCompanyDetailTip', onShow: ' ', onFocus: ' ', onError: "请介绍简要介绍该企业" }).inputValidator({ min: 1, onError: '请介绍简要介绍该企业' });
                    $('input[name="QQ"]').formValidator({ tipID: 'txtQQTip', onShow: ' ', onFocus: '请输入常用QQ号，以便求职者与您联系', onError: " ", empty: true }).regexValidator({ regExp: "^\\d{5,15}$", onError: "格式错误，QQ号应为5-15位的数字" });
                },
                this.InitPage = function (recruitingStr, employerStr) {
                    if (recruitingStr != '') {
                        LoadRecruitingTempleties(recruitingStr);
                    }
                    if (employerStr != '') {
                        LoadCompanyTempleties(employerStr);
                    }
                },
                this.RecoveryFromTemplete = function (sender, id, slt) {
                    if (slt == 1) { //恢复招募单模板 
                        RecoveryRecritingData(sender, id);
                    }
                    else if (slt == 0) { //恢复公司模板
                        RecoveryCompanyData(sender, id);
                    }
                },
                this.ChangeTempletePage = function (sender, pageIndex, slt, recruitingboxId, companyboxId) {
                    var label = $('<span>请稍后......</span>');
                    if (slt == 1) { //更新招募单模板 
                        $.ajax({
                            url: '/CompanyCenter/QueryRecruitingTemplete',
                            data: { page: pageIndex },
                            beforeSend: function () {
                                $(sender).parent().append(label);
                            },
                            success: function (str) {
                                LoadRecruitingTempleties(str);
                                BuildRecruitingTemplete(recruitingboxId);
                            },
                            complete: function () {
                                label.remove();
                            }
                        });
                    }
                    else if (slt == 0) { //更新公司模板
                        $.ajax({
                            url: '/CompanyCenter/QueryCompanyTemplete/',
                            data: { page: pageIndex },
                            beforeSend: function () {
                                $(sender).parent().append(label);
                            },
                            success: function (str) {
                                LoadCompanyTempleties(str);
                                BuildCompanyTemplete(recruitingboxId);
                            },
                            complete: function () {
                                label.remove();
                            }
                        });
                    }
                },
                this.RecoveryFromOriginal = function (data) {
                    SetRecruitingSheet(data);
                }
                this.BuildTempleteList = function (recruitingboxId, companyboxId) {
                    BuildRecruitingTemplete(recruitingboxId);
                    BuildCompanyTemplete(companyboxId);
                },
                this.NewPosition = function (sender) {
                    var box = $('#positionbox');
                    //var o = $(this).children('div').eq(0).children('.right').children('a');
                    var segment = $('<div class="positionitem">' +
                                    '<div class="positionitem-line">' +
                                        '<div class="left">职位名称：<input type="text" class="highlightborder #ffc15c" name="PositionName' + length + '" style="width: 300px" id="txtPositionName' + length + '" /></div>' +
                                        '<div class="left" style="padding-left: 2px;"><div class="textboxs-message1" id="txtPositionName' + length + 'Tip"></div></div>' +
                                        '<div class="left" style="padding-left: 4px;">招聘人数：<input class="highlightborder #ffc15c" name="Vacancy' + length + '" type="text" style="width: 42px" id="txtVacancy' + length + '" value="0" />&nbsp;\'0\'表示若干</div>' +
                                        '<div class="left" style="padding-left: 2px;"><span class="textboxs-message1" id="txtVacancy' + length + 'Tip"></span></div>' +
                                        '<div class="right"><a href="javascript:;" onclick="DeletePosition(this,' + length + ')"><img alt="close" src="/Content/Images/cross.png" /></a></div>' +
                                    '</div>' +
                                    '<div class="positionitem-line">' +
                                        '职位类型：<select name="PositionType' + length + '" id="sltPositionType' + length + '"></select>&nbsp;&nbsp;' +
                                        '薪酬范围：<input type="text" style="width: 40px" name="MinSalary' + length + '"/>&nbsp;--&nbsp;<input type="text" style="width: 40px" name="MaxSalary' + length + '" />&nbsp;（不填表示面议）' +
                                        '结算周期：<select name="Period' + length + '" id="sltPeriod' + length + '"></select>&nbsp;&nbsp; ' +
                                    '</div>' +
                                    '<div class="positionitem-line">' +
                                        '性别要求：<select name="Gender' + length + '">' +
                                            '<option value="-1" selected="selected">不限</option>' +
                                            '<option value="1">男生</option>' +
                                            '<option value="0">女生</option>' +
                                        '</select>&nbsp;&nbsp;' +
                                        '学历要求：<select name="Degree' + length + '" id="sltDegree' + length + '"></select>' +
                                         '<input type="checkbox" name="Experienced' + length + '" id="ckbExperienced' + length + '" /><label for="ckbExperienced' + length + '">有经验者优先</label>' +
                                    '</div>' +
                                    '<div class="positionitem-line">' +
                                        '<div class="left">职位描述：</div>' +
                                        '<div class="left"><textarea style="width: 550px; height: 200px" id="txtPositionDescript' + length + '" name="PositionDescript' + length + '"></textarea></div>' +
                                        '<div style="overflow: hidden; width: 100%; padding-left: 60px;"><div class="left" style="padding-left: 2px;" id="txtPositionDescript' + length + 'Tip"></div></div>' +
                                    '</div>' +
                                '</div>');
                    box.append(segment.fadeIn(600, function () { }));
                    var control = new plug.Control();
                    control.BuildSelect({ element: 'sltPositionType' + length, nobind: [0] }, 'PositionType');
                    control.BuildSelect('sltDegree' + length, 'Degree');
                    control.BuildSelect('sltPeriod' + length, 'Period');
                    $('input[name="PositionName' + length + '"]').formValidator({ tipID: 'txtPositionName' + length + 'Tip', onShow: ' ', onFocus: ' ', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $('input[name="Vacancy' + length + '"]').formValidator({ tipID: 'txtVacancy' + length + 'Tip', onShow: ' ', onFocus: ' ', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^\\d+$", onError: "格式错误" });
                    $('textarea[name="PositionDescript' + length + '"]').formValidator({ tipID: 'txtPositionDescript' + length + 'Tip', onShow: ' ', onFocus: ' ', onError: "职位描述不能为空" }).inputValidator({ min: 1, onError: '职位描述不能为空' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    length += 1;
                    $('input[name="Position"]').val(length);
                },
                DeletePosition = function (sender, index) {
                    $('#txtPositionName' + index).unloadValidator();
                    $('#txtVacancy' + index).unloadValidator();
                    $(sender).parents('.positionitem').remove();
                }
            }
        })(),
        AboutUs: (function () {
            return function () {
                this.BindValidate = function () {
                    $.formValidator.initConfig({ formID: "form1", ErrorTipClass: 'validation-label-error', ErrorElementClass: 'validation-element-error', onSuccess: function (meg) { return true; }, onError: function (msg, obj, errorlist) { return false; } });
                    $("input[name='CompanyName']").formValidator({ tipID: 'txtCompanyNameTip', onShow: ' ', onFocus: ' ', onError: "至少输入3个字符" }).inputValidator({ min: 3, onError: '至少输入3个字符' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("input[name='Location']").formValidator({ tipID: 'txtLocationTip', onShow: ' ', onFocus: ' ', onError: "至少输入5个字符" }).inputValidator({ min: 5, onError: '至少输入5个字符' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("input[name='Phone']").formValidator({ tipID: 'txtPhoneTip', onShow: ' ', onFocus: ' ', onError: "至少输入5个字符" }).inputValidator({ min: 5, onError: '至少输入5个字符' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("input[name='EMail']").formValidator({ tipID: 'txtEmailTip', onShow: ' ', onFocus: ' ', onError: "您的输入有误" }).regexValidator({ regExp: "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", onError: "您的输入有误" }); ;
                    $('input[name="QQ"]').formValidator({ tipID: 'txtQQTip', onShow: ' ', onFocus: '请输入常用QQ号，以便求职者与您联系', onError: " ", empty: true }).regexValidator({ regExp: "^\\d{5,15}$", onError: "格式错误，QQ号应为5-15位的数字" });
                }
            }
        })(),
        NewptJob: (function () {
            var length = 1;
            return function () {
                this.BindValidate = function () {
                    $.formValidator.initConfig({ validatorGroup: "1", ErrorTipClass: 'validation-label-error', ErrorElementClass: 'validation-element-error', onSuccess: function (meg) { return true; }, onError: function (msg, obj, errorlist) { return false; } });
                    $("input[name='Caption']").formValidator({ validatorGroup: "1", tipID: 'txtCaptionTip', onShow: ' ', onFocus: "兼职标题将作为主要信息显示在重庆大学生兼职网上，请输入具有概括性的标题", onError: "至少输入5个字符" }).inputValidator({ min: 5, onError: '至少输入5个字符' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("input[name='ContactMan']").formValidator({ validatorGroup: "1", tipID: 'txtContactManTip', onShow: ' ', onFocus: ' ', onError: "请输入联系人姓名" }).inputValidator({ min: 1, onError: '请输入联系人姓名' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("input[name='ContactPhone']").formValidator({ validatorGroup: "1", tipID: 'txtContactPhoneTip', onShow: ' ', onFocus: ' ', onError: "请输入联系电话" }).inputValidator({ min: 1, max: 30, onError: '请输入联系电话' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("input[name='WorkAddress']").formValidator({ validatorGroup: "1", tipID: 'txtWorkAddressTip', onShow: ' ', onFocus: '', onError: "请输入详细工作地址" }).inputValidator({ min: 1, onError: '请输入详细工作地址' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    //$("#txtDescription").formValidator({ validatorGroup: "1", tipID: 'txtDescriptionTip', onShow: ' ', onFocus: ' ', onError: "详细的兼职描述有助于更快的通过审核和找寻人才" }).inputValidator({ min: 1, onError: '详细的兼职描述有助于更快的通过审核和找寻人才' });
                    $.formValidator.initConfig({ validatorGroup: "2", ErrorTipClass: 'validation-label-error', ErrorElementClass: 'validation-element-error', onSuccess: function (meg) { return true; }, onError: function (msg, obj, errorlist) { return false; } });
                    $('input[name="PositionName0"]').formValidator({ validatorGroup: "2", tipID: 'txtPositionName0Tip', onShow: ' ', onFocus: ' ', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $('input[name="Vacancy0"]').formValidator({ validatorGroup: "2", tipID: 'txtVacancy0Tip', onShow: ' ', onFocus: ' ', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^\\d+$", onError: "格式错误" });
                    $('textarea[name="PositionDescript0"]').formValidator({ validatorGroup: "2", tipID: 'txtPositionDescript0Tip', onShow: ' ', onFocus: ' ', onError: "职位描述不能为空" }).inputValidator({ min: 1, onError: '职位描述不能为空' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $.formValidator.initConfig({ validatorGroup: "3", ErrorTipClass: 'validation-label-error', ErrorElementClass: 'validation-element-error', onSuccess: function (meg) { return true; }, onError: function (msg, obj, errorlist) { return false; } });
                    $('input[name="CompanyName"]').formValidator({ validatorGroup: "3", tipID: 'txtCompanyNameTip', onShow: ' ', onFocus: '必填', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $("#txtCompanyDetail").formValidator({ validatorGroup: "3", tipID: 'txtCompanyDetailTip', onShow: ' ', onFocus: '请简要介绍该企业', onError: "请简要介绍该企业" }).inputValidator({ min: 1, onError: '请介绍简要介绍该企业' });
                    $.formValidator.initConfig({ validatorGroup: "4", ErrorTipClass: 'validation-label-error', ErrorElementClass: 'validation-element-error', onSuccess: function (meg) { return true; }, onError: function (msg, obj, errorlist) { return false; } });
                    $('input[name="UserName"]').formValidator({ validatorGroup: "4", tipID: 'txtUserNameTip', onShow: '下次您使用本用户名登陆', onFocus: '电子邮箱为您的用户名', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", onError: "格式错误，应为电子邮箱" }).ajaxValidator({ onError: "该用户名已存在", url: '/account/usernamevalid', data: { username: $(this).val() }, error: function () { return false; }, success: function (result) { if (result == '1') { return false; } return true; } });
                    $('input[name="CorporationName"]').formValidator({ validatorGroup: "4", tipID: 'txtCorporationNameTip', onShow: '您的个人招聘品牌', onFocus: '必填', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $('input[name="CorpEmail"]').formValidator({ validatorGroup: "4", tipID: 'txtCorpEmailTip', onShow: '您个人企业的企业邮箱。将通过这个邮箱接收求职者简历', onFocus: '请输入可用的电子邮箱', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", onError: "格式错误，应为电子邮箱" });
                    $('input[name="Phone"]').formValidator({ validatorGroup: "4", tipID: 'txtPhoneTip', onShow: '您的联系电话，求职者可能通过此电话与您联系', onFocus: '必填', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                    $('input[name="Location"]').formValidator({ validatorGroup: "4", tipID: 'txtLocationTip', onShow: '您的联系地址', onFocus: '必填', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^[^<>]+$", onError: "请勿包含特殊字符" });
                },
                this.NewPosition = function (sender) {
                    var box = $('#positionbox');
                    //var o = $(this).children('div').eq(0).children('.right').children('a');
                    var segment = $('<div class="positionitem">' +
                                    '<div class="positionitem-line">' +
                                        '<div class="left">职位名称：<input type="text" class="highlightborder #ffc15c" name="PositionName' + length + '" style="width: 335px" id="txtPositionName' + length + '" /></div>' +
                                        '<div class="left" style="padding-left: 2px;"><div class="textboxs-message1" id="txtPositionName' + length + 'Tip"></div></div>' +
                                        '<div class="left" style="padding-left: 4px;">招聘人数：<input class="highlightborder #ffc15c" name="Vacancy' + length + '" type="text" style="width: 42px" id="txtVacancy' + length + '" value="0" />&nbsp;\'0\'表示若干</div>' +
                                        '<div class="left" style="padding-left: 2px;"><span class="textboxs-message1" id="txtVacancy' + length + 'Tip"></span></div>' +
                                        '<div class="right"><a href="javascript:;" onclick="DeletePosition(this,' + length + ')">删除</a></div>' +
                                    '</div>' +
                                    '<div class="positionitem-line">' +
                                        '职位类型：<select name="PositionType' + length + '" id="sltPositionType' + length + '"></select>&nbsp;&nbsp;' +
                                        '薪酬范围：<input type="text" style="width: 40px" name="MinSalary' + length + '"/>&nbsp;--&nbsp;<input type="text" style="width: 40px" name="MaxSalary' + length + '" />&nbsp;（不填表示面议）' +
                                        '结算周期：<select name="Period' + length + '" id="sltPeriod' + length + '"></select>&nbsp;&nbsp; ' +
                                    '</div>' +
                                    '<div class="positionitem-line">' +
                                        '性别要求：<select name="Gender' + length + '">' +
                                            '<option value="-1" selected="selected">不限</option>' +
                                            '<option value="1">男生</option>' +
                                            '<option value="0">女生</option>' +
                                        '</select>&nbsp;&nbsp;' +
                                        '学历要求：<select name="Degree' + length + '" id="sltDegree' + length + '"></select>' +
                                         '<input type="checkbox" name="Experienced' + length + '" id="ckbExperienced' + length + '" /><label for="ckbExperienced' + length + '">有经验者优先</label>' +
                                    '</div>' +
                                    '<div class="positionitem-line">' +
                                        '<div class="left">职位描述：</div>' +
                                        '<div class="left"><textarea style="width: 550px; height: 200px" id="txtPositionDescript' + length + '" name="PositionDescript' + length + '"></textarea></div>' +
                                        '<div style="overflow: hidden; width: 100%; padding-left: 60px;"><div class="left" style="padding-left: 2px;" id="txtPositionDescript' + length + 'Tip"></div></div>' +
                                    '</div>' +
                                '</div>');
                    box.append(segment.fadeIn(600, function () { }));
                    var control = new plug.Control();
                    control.BuildSelect({ element: 'sltPositionType' + length, nobind: [0] }, 'PositionType');
                    control.BuildSelect('sltDegree' + length, 'Degree');
                    control.BuildSelect('sltPeriod' + length, 'Period');
                    $('input[name="PositionName' + length + '"]').formValidator({ validatorGroup: "2", tipID: 'txtPositionName' + length + 'Tip', onShow: ' ', onFocus: ' ', onError: "必填" }).inputValidator({ min: 1, onError: '必填' });
                    $('input[name="Vacancy' + length + '"]').formValidator({ validatorGroup: "2", tipID: 'txtVacancy' + length + 'Tip', onShow: ' ', onFocus: ' ', onError: "必填" }).inputValidator({ min: 1, onError: '必填' }).regexValidator({ regExp: "^\\d+$", onError: "格式错误" });
                    $('textarea[name="PositionDescript' + length + '"]').formValidator({ validatorGroup: "2", tipID: 'txtPositionDescript' + length + 'Tip', onShow: ' ', onFocus: ' ', onError: "职位描述不能为空" }).inputValidator({ min: 1, onError: '职位描述不能为空' });
                    length += 1;
                    $('input[name="Position"]').val(length);
                },
                DeletePosition = function (sender, index, groupid) {
                    $('#txtPositionName' + index).unloadValidator(groupid);
                    $('#txtVacancy' + index).unloadValidator(groupid);
                    $(sender).parents('.positionitem').remove();
                }
            }
        })()
    }
})();
